(function(window, $, undefined) { var _block_namespaces_ = window._block_namespaces_ || (window._block_namespaces_ = {}); var name = "blockLA25034"; var blockLA25034 = _block_namespaces_[name] || (_block_namespaces_[name] = {}); $.extend(blockLA25034, { "init": init }) function init(nodeObj) { if (!!!nodeObj) { return; } var $selector = $('div[data-settingid=' + nodeObj.settingId + ']'); // 标签 var labelShow = function(){ var original_html = $selector.find('.block-24584').html(); var isFrontend = window.$_phoenix == undefined; var str = ''; var pre = $selector.find(".proshow-scroll-item"); //获取添加data-pid 的元素; var resopnse; pre.each(function(i,data){ //遍历元素获每个pid 拼接成 str var pid = $(this).data('pid'); i===pre.length-1 ? str+=pid:str+=pid+"," }) if(isFrontend){ url='/phoenix/admin/prod/label/get' }else{ url='/prod/label/get' } $.ajax ({ url: '/prod/label/get', type: 'GET', dataType: 'json', data: { ids: str }, success: function(data) { $selector.find('.proshow-scroll-item').each(function(index, el){ //遍历每个标题下的产品块的每个产品 var pid = $(el).attr('data-pid'); //获取每个产品星级的pid; if(!(data[pid].length === 0)) { //判断是否添加标签 length不为0 说明有添加标签 var lebal_html=''; var lebal_html_img = ''; for(var i = 0; i < data[pid].length; i++) { //遍历每个标签 //判断是否自定义 if(data[pid][i].labelDivision === "1"){ //判断自定义文本 if(data[pid][i].showType === '0') { //左上角处理 if(data[pid][i].showPositon === '0') { lebal_html =lebal_html+ '
'+data[pid][i].labelName+'
'; $(el).find('.lebal_box').html(lebal_html); //插入.lebal_box中 }else if(data[pid][i].showPositon === '1') { //右上角处理 lebal_html = lebal_html +'
'+data[pid][i].labelName+'
'; $(el).find('.lebal_box').html(lebal_html); }else if(data[pid][i].showPositon === '2'){ //图片上方处理 lebal_html = lebal_html + ''+data[pid][i].labelName+'' $(el).find('.img_top').html(lebal_html); $(el).find('.lebal_box').html(lebal_html); }else if(data[pid][i].showPositon === '4') { //标题前添加标签处理 $(el).find(' .showPositon_title').css({'background-color':data[pid][i].backgroundColor,'color':data[pid][i].fontColor,'padding':'0 5px'}) $(el).find('.showPositon_title').html(data[pid][i].labelName); } //自定义图片处理 }else { //图片右侧; if(data[pid][i].showPositon === '3') { lebal_html_img = lebal_html_img + '
'; $(el).find('.lebal_img_box').html(lebal_html_img); }else if(data[pid][i].showPositon === '1') { //图片在右上侧 lebal_html_img = lebal_html_img + '
'; $(el).find('.lebal_img_box').html(lebal_html_img); }else if(data[pid][i].showPositon === '0') { //图片左上侧 lebal_html_img = lebal_html_img + '
'; $(el).find('.lebal_img_box').html(lebal_html_img); } } }else { //默认 } } } }) original_html = $selector.find('.block-24584').html(); } }) }; labelShow(); var h = 0; setTimeout(function() { $selector.find(".LA25034 .proshow-scroll-item").each(function() { if ($(this).find('.proshow-title').height() > h) h = $(this).find('.proshow-title').height(); }); $selector.find(".proshow-title").height(h); }, 500) $(window).resize(function() { setTimeout(function() { var h = 0; $selector.find(".LA25034 .proshow-scroll-item").each(function() { if ($(this).find('.proshow-title').height() > h) h = $(this).find('.proshow-title').height(); }); $selector.find(".proshow-title").height(h); }, 500) }) var name = ""; name = $selector.find('.product_title .backstage-blocksEditor-wrap').html(); if (!$.trim(name)) { $selector.find('.product_title').css('display', 'none') } else { $selector.find('.product_title').css('display', 'block') } var swiper = new Swiper('div[data-settingid=' + nodeObj.settingId + '] .swiper-LA25034', { slidesPerView: 4, spaceBetween: 20, pagination: { el:'div[data-settingid=' + nodeObj.settingId + '] .swiper-pagination', type: 'progressbar', }, navigation: { nextEl: '.Right', prevEl: '.Left', }, breakpoints: { //当宽度小于等于768时显示 1200: { slidesPerView: 3, }, 800: { slidesPerView: 2, }, 600: { slidesPerView: 1, autoHeight: true, }, }, }) // $selector.find('.LA25034 .proshow-scroll-list').slick({ // dots: false, // infinite: false, // speed: 500, // slidesToShow: 4, // slidesToScroll: 1, // arrows: true, // variableWidth: false, // prevArrow: $selector.find('.Left'), // nextArrow: $selector.find('.Right'), // responsive: [{ // breakpoint: 1200, // settings: { // dots: true, // arrows: false, // slidesToShow: 3, // } // }, { // breakpoint: 800, // settings: { // dots: true, // arrows: false, // slidesToShow: 2, // } // }, { // breakpoint: 510, // settings: { // dots: true, // arrows: false, // slidesToShow: 1, // adaptiveHeight: true, // } // }] // }); } })(window, jQuery);